BLOCK.BlockName = "Computer Core";
BLOCK.Health = 99999999;
BLOCK.PlayerSpawn = false;
BLOCK.HackTime = 10;
BLOCK.HackDuration = 30;
BLOCK.Model = "models/props_combine/combine_interface002.mdl";

BLOCK.alarm = Sound("ambient/alarms/alarm_citizen_loop1.wav");
BLOCK.sound = nil;

function BLOCK:Init()
	if(SERVER) then self.sound = CreateSound(self.SENT.Entity, self.alarm); end
end

function BLOCK:Hack( ply )
	local blocks = hook.Call("GetTeamBlocks", nil, self.Team);
	for key, val in pairs(blocks) do
		local ent = ents.GetByIndex(val);
		if(ent:EntIndex() != self.SENT.Entity:EntIndex() && ent.block.HackTime != 0) then
			ent:ForceHackEnd();
			ent:Hack(ply, self.HackDuration);
		end
	end
	
	local players = player.GetAll();
	for key, val in pairs(players) do
		val:PrintMessage(HUD_PRINTCENTER, team.GetName(self.Team) .. " COMPUTER WAS HACKED!!!");
	end
	
	self.sound:Play();
end

function BLOCK:EndHack()
	self.sound:Stop();
end